SimpleRpgCollisionUpdater = function(go, collideables) {
    Updater.call(this, go);
    this.collideables = collideables;
};

SimpleRpgCollisionUpdater.prototype = Object.create(Updater.prototype);

SimpleRpgCollisionUpdater.prototype.run = function() {
    var collideables = this.collideables;
    var obj = this.gameObject;
    var moveX = obj.vx;
    var moveY = obj.vy;
    var bounds = getBounds(obj);

    var collisions = calculateRectCollision(obj, collideables);


    if (collisions) {
        for (var i = 0; i < collisions.length; i++) {
            var inter = collisions[i];
            var cbounds = getBounds(inter.collisioned);

            var diffX = bounds.x - cbounds.x;
            var signX = diffX / Math.abs(diffX);
            var diffY = bounds.y - cbounds.y;
            var signY = diffY / Math.abs(diffY);

            var move = {
                x:Math.ceil(inter.width) * signX ,
                y:Math.ceil(inter.height) * signY
            };

            /*signY es positivo si la colision es de arriba a abajo.es
             negativo si la colision es de abajo hacia arriba*/
             var roofHit= signY > 0 ? true : false;

            if (inter.height >= inter.width) {
                /*si la colision fue frontal entonces la 
                altura de la misma sera superior a la anchura*/
                moveX = move.x || signX;
            } else {
                if(roofHit){
                    writeOnCanvas("roof hit!",25,75);
                }
                moveY = move.y || signY;
            }

        }
    }

    obj.move(moveX, moveY);
};
